//
//  DKOrderDetailsCell.m
//  DanKU
//
//  Created by EDY on 2023/11/6.
//

#import "DKOrderDetailsCell.h"
#import "OrderTool.h"


@interface DKOrderDetailsCell()

@property(nonatomic,strong)UIView *dk_OrderRepayView;
@property(nonatomic,strong)UILabel *dk_repayLeftlab;
@property(nonatomic,strong)UILabel *dk_repayRightlab;

@end

@implementation DKOrderDetailsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor =  DK_Hex(@"#FAFAFA");
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self creatUI];
    }
    return  self;
}

-(void)setPairsSoure:(DKOrderDetailPairsModel *)PairsSoure{
    self.dk_repayLeftlab.text = PairsSoure.key;
    self.dk_repayRightlab.text = PairsSoure.value;
    if ([PairsSoure.value containsString:@"color="]) {
        NSDictionary *diction = [OrderTool parseHTMLString:PairsSoure.value];
        if ([diction objectForKey:@"Font"]) {
            self.dk_repayRightlab.text = [diction objectForKey:@"Font"];
        }
        
        if ([diction objectForKey:@"Color"]) {
            self.dk_repayRightlab.textColor = DK_Hex([diction objectForKey:@"Color"]);
        }
    }
}


-(void)setExtensionSoure:(DKDelayFlexibleExtensionModel *)extensionSoure{
    self.dk_repayLeftlab.text = extensionSoure.key;
    self.dk_repayRightlab.text = extensionSoure.value;
    if ([extensionSoure.value containsString:@"color="]) {
        NSDictionary *diction = [OrderTool parseHTMLString:extensionSoure.value];
        if ([diction objectForKey:@"Font"]) {
            self.dk_repayRightlab.text = [diction objectForKey:@"Font"];
        }
        
        if ([diction objectForKey:@"Color"]) {
            self.dk_repayRightlab.textColor = DK_Hex([diction objectForKey:@"Color"]);
        }
    }
}

-(void)creatUI{
    [self.contentView addSubview:self.dk_OrderRepayView];
    [self.dk_OrderRepayView addSubview:self.dk_repayLeftlab];
    [self.dk_OrderRepayView addSubview:self.dk_repayRightlab];
    
    [self.dk_OrderRepayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    [self.dk_repayLeftlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_OrderRepayView).offset(15);
        make.width.mas_equalTo(DK_SCREEN_W/2-50);
        make.top.bottom.equalTo(self.dk_OrderRepayView);
    }];
    
    [self.dk_repayRightlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.dk_OrderRepayView).offset(-15);
        make.width.mas_equalTo(DK_SCREEN_W/2-10);
        make.top.bottom.equalTo(self.dk_repayLeftlab);
    }];
}

-(UIView*)dk_OrderRepayView{
    if (!_dk_OrderRepayView) {
        _dk_OrderRepayView = [[UIView alloc]init];
        _dk_OrderRepayView.backgroundColor = DK_Hex(@"#FFFFFF");
        _dk_OrderRepayView.layer.cornerRadius = 10;
    }
    return _dk_OrderRepayView;
}


- (UILabel *)dk_repayLeftlab {
    if (!_dk_repayLeftlab) {
        _dk_repayLeftlab = [[UILabel alloc] init];
        _dk_repayLeftlab.textColor = DK_Hex(@"#999999");
        _dk_repayLeftlab.font = [UIFont boldSystemFontOfSize:13];
        _dk_repayLeftlab.text = @"Due data";
    }
    return _dk_repayLeftlab;
}

- (UILabel *)dk_repayRightlab {
    if (!_dk_repayRightlab) {
        _dk_repayRightlab = [[UILabel alloc] init];
        _dk_repayRightlab.textColor = DK_Hex(@"#3333333");
        _dk_repayRightlab.font = [UIFont boldSystemFontOfSize:13];
        _dk_repayRightlab.text = @"Due data";
        _dk_repayRightlab.textAlignment = 2;
        _dk_repayRightlab.numberOfLines = 0;
    }
    return _dk_repayRightlab;
}

@end
